// pages/indexsou/indexsou.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    remen: app.data.url +'/uploads/zhongxue/huo.png',
    gettiaojian: app.data.url +"/zhongxue/maoapi/sousuo",
    shousuo_remen:[
      "初中英语", "小学英语", "初二化学","小学语文"
    ],
    shousuo_lishi:[
      "初中英语", "小学英语", "初二化学"
    ],
    tiaojian:"请输入你要报名的课程",
    zhongbiao: app.data.url +'/uploads/zhongxue/zhongbiao.png',
    chachas: app.data.url +'/uploads/zhongxue/chachas.png',
    shuju:[],


    statu:true,
    husourimge: app.data.url +'/uploads/zhongxue/sousuo.png',
    huo: app.data.url +'/uploads/zhongxue/huo.png',
    delet: app.data.url +'/uploads/zhongxue/delet.png',
    zhongbiao: app.data.url +'/uploads/zhongxue/zhongbiao.png',
    chachas: app.data.url +'/uploads/zhongxue/chachas.png',
    sousuos: [
      { src: app.data.url +'/uploads/zhongxue/huo.png',text:'初中英语'},
      { src: app.data.url +'/uploads/zhongxue/huo.png', text: '初中英语' },
      { src: app.data.url +'/uploads/zhongxue/huo.png', text: '初中英语' },
      { src: app.data.url +'/uploads/zhongxue/huo.png', text: '初一11111中英语' },
      { src: app.data.url +'/uploads/zhongxue/huo.png', text: '初中英语' },
      { src: '', text: '初中英语' },
      { src: '', text: '初中英语' },
      { src: '', text: '初中英语' },
      { src: '', text: '初中英语' },
      { src: '', text: '初中英语' },
    ],
    hismain:["初中英语","小学英语","初二化学"],
 
    


  },


  huoqu:function(e){
    var value = e.detail.value;
    if (value == "") {

      this.setData({
        statu: true,
      })
    } else {
      this.setData({
        statu: false,
      })

    }
  },
  resou:function(e){
    var str = e.currentTarget.dataset.str;
    this.setData({tiaojian:str});
  },
  golishi:function(e){
    var str = e.currentTarget.dataset.str;
    this.setData({tiaojian:str});
  },
  sigups:function(e){
    console.log(e);
    var go = e.currentTarget.dataset.go;
    var phton = e.currentTarget.dataset.phone;
    if(go==0){
      wx.showModal({
        title: '提示',
        content: '本班报名已结束，是否给老师打电话？',
        success:function(e){
          if (e.confirm){
            wx.makePhoneCall({
              phoneNumber: phton,
              success: function(res) {},
              fail: function(res) {},
              complete: function(res) {},
            })
          }
        }
      })
      return
    }
    var id = e.currentTarget.dataset.id;
    var user = wx.getStorageSync('user');
    if (user.denglu!==1){
      wx.showToast({
        title: '你还没有登录！',
        icon: 'none',

        duration:app.data.quanbushijian
      })
      setTimeout(function () {
        wx.navigateTo({
          url: '/pages/login/login',
        })
      }, 1300)
      return;
    }
    wx.navigateTo({
      url: '/pages/lgsigup/lgsigup?id=' + id,
    })
  },
  
  //获取键盘输入的历史这些
  shiqu:function(e){
    var value = e.detail.value;
    this.setData({ tiaojian:value})

  },
  sousuo:function(){
    var tiaojian = this.data.tiaojian;
    this.setData({
      statu: false,
    })
    var user = wx.getStorageSync('user');
    var that = this;
    console.log(tiaojian);
    wx.showLoading({
      title: '搜索中',
    })
    wx.request({
      url: that.data.gettiaojian,
      data: {token:user.token,tiaojian:tiaojian},
      header: {},
      method: 'POST',
      dataType: 'json',
      responseType: 'text',
      success: function(res) {
        var data = res.data;
        console.log(data.data);
        if(data.code==200){
          that.setData({shuju:data.data})
        }else{
          wx.showToast({
            title: data.msg,
            icon:'none',
            duration:app.data.quanbushijian
          })
        }
      },
      fail: function(res) {},
      complete: function(res) {
        wx.hideLoading()
      },
    })
  },
  
  

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
      path: '/pages/indexfirst/indexfirst',
    }
  }
})